<html><!-- Created using the cpp_pretty_printer from the dlib C++ library.  See http://dlib.net for updates. --><head><title>dlib C++ Library - auto_unlock_extension_abstract.h</title></head><body bgcolor='white'><pre>
<font color='#009900'>// Copyright (C) 2006  Davis E. King (davis@dlib.net)
</font><font color='#009900'>// License: Boost Software License   See LICENSE.txt for the full license.
</font><font color='#0000FF'>#undef</font> DLIB_AUTO_UNLOCK_EXTENSIOn_ABSTRACT_
<font color='#0000FF'>#ifdef</font> DLIB_AUTO_UNLOCK_EXTENSIOn_ABSTRACT_

<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='threads_kernel_abstract.h.html'>threads_kernel_abstract.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='rmutex_extension_abstract.h.html'>rmutex_extension_abstract.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='read_write_mutex_extension_abstract.h.html'>read_write_mutex_extension_abstract.h</a>"

<font color='#0000FF'>namespace</font> dlib
<b>{</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>class</font> <b><a name='auto_unlock'></a>auto_unlock</b>
    <b>{</b>
        <font color='#009900'>/*!
            INITIAL VALUE
                The mutex given in the constructor is associated with this object.

            WHAT THIS OBJECT REPRESENTS
                This object represents a mechanism for automatically unlocking
                a mutex object.  It is useful when you already have a locked mutex
                and want to make sure it gets unlocked even if an exception is thrown 
                or you quit the function at a weird spot.
        !*/</font>
    <font color='#0000FF'>public</font>:

        <font color='#0000FF'>explicit</font> <b><a name='auto_unlock'></a>auto_unlock</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> mutex<font color='#5555FF'>&amp;</font> m
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - #*this is properly initialized
                - does not modify m in any way 
        !*/</font>

        <font color='#0000FF'>explicit</font> <b><a name='auto_unlock'></a>auto_unlock</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> rmutex<font color='#5555FF'>&amp;</font> m
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - #*this is properly initialized
                - does not modify m in any way 
        !*/</font>

        <font color='#0000FF'>explicit</font> <b><a name='auto_unlock'></a>auto_unlock</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> read_write_mutex<font color='#5555FF'>&amp;</font> m
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - #*this is properly initialized
                - does not modify m in any way 
        !*/</font>

        ~<b><a name='auto_unlock'></a>auto_unlock</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - all resources allocated by *this have been freed
                - calls unlock() on the mutex associated with *this
        !*/</font>

    <font color='#0000FF'>private</font>:
        <font color='#009900'>// restricted functions
</font>        <b><a name='auto_unlock'></a>auto_unlock</b><font face='Lucida Console'>(</font>auto_unlock<font color='#5555FF'>&amp;</font><font face='Lucida Console'>)</font>;        <font color='#009900'>// copy constructor
</font>        auto_unlock<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>=</font><font face='Lucida Console'>(</font>auto_unlock<font color='#5555FF'>&amp;</font><font face='Lucida Console'>)</font>;    <font color='#009900'>// assignment operator
</font>    <b>}</b>;

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>class</font> <b><a name='auto_unlock_readonly'></a>auto_unlock_readonly</b>
    <b>{</b>
        <font color='#009900'>/*!
            INITIAL VALUE
                The mutex given in the constructor is associated with this object.

            WHAT THIS OBJECT REPRESENTS
                This object represents a mechanism for automatically unlocking
                a read_write_mutex object.  It is useful when you already have a locked mutex
                and want to make sure it gets unlocked even if an exception is thrown 
                or you quit the function at a weird spot.  Note that the mutex
                is unlocked by calling unlock_readonly() on it.
        !*/</font>
    <font color='#0000FF'>public</font>:

        <font color='#0000FF'>explicit</font> <b><a name='auto_unlock_readonly'></a>auto_unlock_readonly</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> read_write_mutex<font color='#5555FF'>&amp;</font> m
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - #*this is properly initialized
                - does not modify m in any way 
        !*/</font>

        ~<b><a name='auto_unlock_readonly'></a>auto_unlock_readonly</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font>;
        <font color='#009900'>/*!
            ensures
                - all resources allocated by *this have been freed
                - calls unlock_readonly() on the mutex associated with *this
        !*/</font>

    <font color='#0000FF'>private</font>:
        <font color='#009900'>// restricted functions
</font>        <b><a name='auto_unlock_readonly'></a>auto_unlock_readonly</b><font face='Lucida Console'>(</font>auto_unlock_readonly<font color='#5555FF'>&amp;</font><font face='Lucida Console'>)</font>;        <font color='#009900'>// copy constructor
</font>        auto_unlock_readonly<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>=</font><font face='Lucida Console'>(</font>auto_unlock_readonly<font color='#5555FF'>&amp;</font><font face='Lucida Console'>)</font>;    <font color='#009900'>// assignment operator
</font>    <b>}</b>;

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
<b>}</b>

<font color='#0000FF'>#endif</font> <font color='#009900'>// DLIB_AUTO_UNLOCK_EXTENSIOn_ABSTRACT_
</font>


</pre></body></html>